import { getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { BitmapRenderer } from "../engine/BitmapRenderer";
import { TextRenderer } from "../engine/TextRenderer";
import { number } from "../engine/validators/number";
import { ChangeScene } from "./ChangeScene";
import { Clock } from "./Clock";
import { Tip } from "./Tip";

export class Bill_OK_Click extends Behaviour {

    dayNum = 1
    //天数界面跳转回学校界面的flag
    changeFlag = false

    onStart() {
        this.gameObject.onClick = () => {
            //每次结束一天，currentday++
            this.dayNum ++ 
            this.changeFlag = true
             console.log("按钮的flag：" + this.changeFlag)
            console.log("  下一天：" + this.dayNum)

            //为了实时响应就把改变文字和图片的放到这里了
            //=========================在这里重置计时==========================
            getGameObjectById('UI_time_text').getBehaviour(Clock).start = false
            getGameObjectById('UI_time_text').getBehaviour(Clock).dayEnd = true
            getGameObjectById('UI_time_text').getBehaviour(TextRenderer).text = "24：00"
            getGameObjectById('UI_time_sun2').getBehaviour(BitmapRenderer).source =  "./assets/images/UI_time_8sun.png"
            console.log("计时状态：" + getGameObjectById('UI_time_text').getBehaviour(Clock).start)
            //让满意度重置
            getGameObjectById('UI_satisfaction_text').getBehaviour(Tip).reset = true
            getGameObjectById('UI_satisfaction_text').getBehaviour(TextRenderer).text = "100"
            getGameObjectById('UI_satisfaction_smileFace').getBehaviour(BitmapRenderer).source =  "./assets/images/UI_satisfaction_smileFace.png"


            //账单数据清零
            getGameObjectById('Text_Income').getBehaviour(TextRenderer).text="0";
            getGameObjectById('Text_cost').getBehaviour(TextRenderer).text="0";
            getGameObjectById('Text_Fee').getBehaviour(TextRenderer).text="0";
            getGameObjectById('Text_profit').getBehaviour(TextRenderer).text="0";
            //getGameObjectById('Text_day_number').getBehaviour(TextRenderer).text="";




            this.engine.scenenumber=4;
            //getGameObjectById('changeScene').getBehaviour(ChangeScene).LoadScene("scene2");


            
        };
    }

    onTick(duringTime: number) {

    }
}